package com.project.erp.model.contract.trade;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.struts2.json.annotations.JSON;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.google.common.collect.Lists;
import com.project.erp.model.IdEntity;
import com.project.erp.model.fobcost.FobCost;

/**
 * 
 * COPYRIGHT (C) 2013 BY XXX公司
 * 
 * 功能模块名：外贸-客户合同
 * 
 * 功能描述：外贸客户合同表
 * 
 * @author LiJiaGuo
 * 
 * @version 1.0
 * 
 * @created 2013-12-13 下午11:04:00
 */
@Entity
// 表名与类名不相同时重新定义表名.
@Table(name = "TBL_TRADECUS_CONTRACT")
// 默认的缓存策略.
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class TradeCusContract extends IdEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1097273935176665218L;

	private String inexpComName;// 进出口公司
	private String inexpComAddress;// 进出口公司地址
	private String companyName;// 己方公司名称
	private String companyAddress;// 己方公司地址
	private String companyEmail;// 己方公司邮箱
	private String companyMob;// 己方公司手机号
	private String companyTel;// 己方公司座机号
	private String companyFax;// 己方公司传真
	private String cusAddress;// 客户地址
	private String cusTelFax;// 客户电话传真
	private String cusEmail;// 客户邮箱
	private String invoiceNo;// 合同编号
	private String invoiceDate;// 合同生成时间
	private Double totTotalConts;//
	private Double totTotalBoxs;// 统计总盒数
	private Double totTotalPcs;// 统计总箱数
	private Double totTotalMtwos;// 统计总平方数
	private Double totTotalAmount;// 统计总金额
	private String totTotalAmountEn;// 统计总金额(英文)
	private String benBankName;// 汇款银行名称
	private String benBankCode;// 汇款银行代号
	private String swiftCode;// 汇款银行识别码
	private String acName;// 账号所属
	private String acCode;// 账号
	private String createUser;// 创建用户
	private Date createTime;// 创建时间
	private String updateUser;// 更新用户
	private Date updateTime;// 更新时间
	
	private Date startTime;	//创建开始时间--用于查询
	private Date endTime;		//创建结束时间--用于查询
	
	//主表关联细表
	private List<FobCost> fobCostList = Lists.newArrayList(); //有序的关联对象集合
	private List<TradeCusContractDtl> tradeCusContractDtlList = Lists.newArrayList(); //有序的关联对象集合

	@Column(columnDefinition="varchar(200)")
	public String getInexpComName() {
		return inexpComName;
	}

	public void setInexpComName(String inexpComName) {
		this.inexpComName = inexpComName;
	}

	@Column(columnDefinition="varchar(300)")
	public String getInexpComAddress() {
		return inexpComAddress;
	}

	public void setInexpComAddress(String inexpComAddress) {
		this.inexpComAddress = inexpComAddress;
	}

	@Column(columnDefinition="varchar(200)")
	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

	@Column(columnDefinition="varchar(300)")
	public String getCompanyAddress() {
		return companyAddress;
	}

	public void setCompanyAddress(String companyAddress) {
		this.companyAddress = companyAddress;
	}

	@Column(columnDefinition="varchar(100)")
	public String getCompanyEmail() {
		return companyEmail;
	}

	public void setCompanyEmail(String companyEmail) {
		this.companyEmail = companyEmail;
	}

	@Column(columnDefinition="varchar(100)")
	public String getCompanyMob() {
		return companyMob;
	}

	public void setCompanyMob(String companyMob) {
		this.companyMob = companyMob;
	}

	@Column(columnDefinition="varchar(100)")
	public String getCompanyTel() {
		return companyTel;
	}

	public void setCompanyTel(String companyTel) {
		this.companyTel = companyTel;
	}

	@Column(columnDefinition="varchar(100)")
	public String getCompanyFax() {
		return companyFax;
	}

	public void setCompanyFax(String companyFax) {
		this.companyFax = companyFax;
	}

	@Column(columnDefinition="varchar(300)")
	public String getCusAddress() {
		return cusAddress;
	}

	public void setCusAddress(String cusAddress) {
		this.cusAddress = cusAddress;
	}

	@Column(columnDefinition="varchar(100)")
	public String getCusTelFax() {
		return cusTelFax;
	}

	public void setCusTelFax(String cusTelFax) {
		this.cusTelFax = cusTelFax;
	}

	@Column(columnDefinition="varchar(100)")
	public String getCusEmail() {
		return cusEmail;
	}

	public void setCusEmail(String cusEmail) {
		this.cusEmail = cusEmail;
	}

	@Column(columnDefinition="varchar(50)")
	public String getInvoiceNo() {
		return invoiceNo;
	}

	public void setInvoiceNo(String invoiceNo) {
		this.invoiceNo = invoiceNo;
	}

	
	@Column(columnDefinition="varchar(50)")
	public String getInvoiceDate() {
		return invoiceDate;
	}

	public void setInvoiceDate(String invoiceDate) {
		this.invoiceDate = invoiceDate;
	}

	@Column(nullable=false)
	public Double getTotTotalConts() {
		return totTotalConts;
	}

	public void setTotTotalConts(Double totTotalConts) {
		this.totTotalConts = totTotalConts;
	}

	@Column(nullable=false)
	public Double getTotTotalBoxs() {
		return totTotalBoxs;
	}

	public void setTotTotalBoxs(Double totTotalBoxs) {
		this.totTotalBoxs = totTotalBoxs;
	}

	@Column(nullable=false)
	public Double getTotTotalPcs() {
		return totTotalPcs;
	}

	public void setTotTotalPcs(Double totTotalPcs) {
		this.totTotalPcs = totTotalPcs;
	}

	@Column(nullable=false)
	public Double getTotTotalMtwos() {
		return totTotalMtwos;
	}

	public void setTotTotalMtwos(Double totTotalMtwos) {
		this.totTotalMtwos = totTotalMtwos;
	}

	@Column(nullable=false)
	public Double getTotTotalAmount() {
		return totTotalAmount;
	}

	public void setTotTotalAmount(Double totTotalAmount) {
		this.totTotalAmount = totTotalAmount;
	}

	@Column(columnDefinition="varchar(300)")
	public String getTotTotalAmountEn() {
		return totTotalAmountEn;
	}

	public void setTotTotalAmountEn(String totTotalAmountEn) {
		this.totTotalAmountEn = totTotalAmountEn;
	}

	@Column(columnDefinition="varchar(100)")
	public String getBenBankName() {
		return benBankName;
	}

	public void setBenBankName(String benBankName) {
		this.benBankName = benBankName;
	}

	@Column(columnDefinition="varchar(100)")
	public String getBenBankCode() {
		return benBankCode;
	}

	public void setBenBankCode(String benBankCode) {
		this.benBankCode = benBankCode;
	}

	@Column(columnDefinition="varchar(100)")
	public String getSwiftCode() {
		return swiftCode;
	}

	public void setSwiftCode(String swiftCode) {
		this.swiftCode = swiftCode;
	}

	@Column(columnDefinition="varchar(200)")
	public String getAcName() {
		return acName;
	}

	public void setAcName(String acName) {
		this.acName = acName;
	}

	@Column(columnDefinition="varchar(100)")
	public String getAcCode() {
		return acCode;
	}

	public void setAcCode(String acCode) {
		this.acCode = acCode;
	}

	@Column(columnDefinition="varchar(30)")
	public String getCreateUser() {
		return createUser;
	}

	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}

	@JSON(format="yyyy-MM-dd")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(columnDefinition="varchar(30)")
	public String getUpdateUser() {
		return updateUser;
	}

	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}

	@JSON(format="yyyy-MM-dd")
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@Transient
	@JSON(format="yyyy-MM-dd")
	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	@Transient
	@JSON(format="yyyy-MM-dd")
	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	//多对多定义
	@ManyToMany(fetch=FetchType.LAZY)
	//中间表定义,表名采用默认命名规则
	@JoinTable(name = "TBL_TRADECONTRACT_FOBCOST", joinColumns = {@JoinColumn(name = "CONTRACT_ID") }, inverseJoinColumns = { @JoinColumn(name = "FOBCOST_ID") })
	//Fecth策略定义
	@Fetch(FetchMode.SUBSELECT)
	//集合按id排序
	@OrderBy("id DESC")
	public List<FobCost> getFobCostList() {
		return fobCostList;
	}

	public void setFobCostList(List<FobCost> fobCostList) {
		this.fobCostList = fobCostList;
	}

	@OneToMany(mappedBy="tradeCusContract")
	@Cascade(value = {CascadeType.SAVE_UPDATE,CascadeType.DELETE,CascadeType.ALL})
	public List<TradeCusContractDtl> getTradeCusContractDtlList() {
		return tradeCusContractDtlList;
	}

	public void setTradeCusContractDtlList(
			List<TradeCusContractDtl> tradeCusContractDtlList) {
		this.tradeCusContractDtlList = tradeCusContractDtlList;
	}
}
